<?php
/**
*
* @package express
* @version $Id: install_3.php,v 1.002 2008/03/22 09:24:00 bb4dd Exp $
* @copyright (c) 2009 bb4dd 
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . '/common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

// Auto detect tables and define them
if (!defined('EXPRESS_CATEGORIES_TABLE'))
{
	define('EXPRESS_CATEGORIES_TABLE',	$table_prefix . 'express_categories');
	define('EXPRESS_ARTICLES_TABLE',	$table_prefix . 'express_articles');
	define('EXPRESS_BLOCKS_TABLE',		$table_prefix . 'express_blocks');
	define('EXPRESS_PAGES_TABLE',		$table_prefix . 'express_pages');
	define('EXPRESS_ADS_TABLE',			$table_prefix . 'express_ads');
	define('EXPRESS_LINKS_TABLE',		$table_prefix . 'express_links');
}

// Create new tables
switch ($db->sql_layer)
{
	case 'firebird':
		$sql_ary = array(
			"CREATE TABLE {$table_prefix}express_categories (
				cat_id INTEGER NOT NULL,
				cat_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
				cat_order INTEGER DEFAULT 0 NOT NULL,
				cat_icon VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
				cat_articles INTEGER DEFAULT 0 NOT NULL,
				cat_desc VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
				display_on_index INTEGER DEFAULT 1 NOT NULL
			);",

			"ALTER TABLE {$table_prefix}express_categories ADD PRIMARY KEY (cat_id);",

			"CREATE INDEX {$table_prefix}express_categories_cat_order ON {$table_prefix}express_categories(cat_order);",

			"CREATE GENERATOR {$table_prefix}express_categories_gen;",

			"SET GENERATOR {$table_prefix}express_categories_gen TO 0;",

			"CREATE TRIGGER t_{$table_prefix}express_categories FOR {$table_prefix}express_categories
			BEFORE INSERT
			AS
			BEGIN
				NEW.cat_id = GEN_ID({$table_prefix}express_categories_gen, 1);
			END;",

			"CREATE TABLE {$table_prefix}express_articles (
				article_id INTEGER NOT NULL,
				article_cat INTEGER DEFAULT 0 NOT NULL,
				article_title VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
				article_intro BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
				article_content BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
				article_content_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
				article_content_options INTEGER DEFAULT 7 NOT NULL,
				article_content_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL,
				article_views INTEGER DEFAULT 0 NOT NULL,
				article_rates INTEGER DEFAULT 0 NOT NULL,
				article_ratings INTEGER DEFAULT 0 NOT NULL,
				article_comments INTEGER DEFAULT 0 NOT NULL,
				article_image VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
				article_similar VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
				article_source VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
				article_time INTEGER DEFAULT 0 NOT NULL
			);",

			"ALTER TABLE {$table_prefix}express_articles ADD PRIMARY KEY (article_id);",

			"CREATE GENERATOR {$table_prefix}express_articles_gen;",

			"SET GENERATOR {$table_prefix}express_articles_gen TO 0;",

			"CREATE TRIGGER t_{$table_prefix}express_articles FOR {$table_prefix}express_articles
			BEFORE INSERT
			AS
			BEGIN
				NEW.article_id = GEN_ID({$table_prefix}express_articles_gen, 1);
			END;",

			"CREATE TABLE {$table_prefix}express_pages (
				page_id INTEGER NOT NULL,
				page_basename VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL,
				page_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
				page_custom INTEGER DEFAULT 0 NOT NULL,
				page_order INTEGER DEFAULT 0 NOT NULL,
				page_icon VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
				page_views INTEGER DEFAULT 0 NOT NULL,
				page_content BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
				page_content_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
				page_content_options INTEGER DEFAULT 7 NOT NULL,
				page_content_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL,
				page_time INTEGER DEFAULT 0 NOT NULL,
				template_file VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
				language_file VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL
			);",

			"ALTER TABLE {$table_prefix}express_pages ADD PRIMARY KEY (page_id);",

			"CREATE INDEX {$table_prefix}express_pages_page_order ON {$table_prefix}express_pages(page_order);",

			"CREATE GENERATOR {$table_prefix}express_pages_gen;",

			"SET GENERATOR {$table_prefix}express_pages_gen TO 0;",

			"CREATE TRIGGER t_{$table_prefix}express_pages FOR {$table_prefix}express_pages
			BEFORE INSERT
			AS
			BEGIN
				NEW.page_id = GEN_ID({$table_prefix}express_pages_gen, 1);
			END;",

			"CREATE TABLE {$table_prefix}express_blocks (
				block_id INTEGER NOT NULL,
				block_title VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
				block_type VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL,
				block_position INTEGER DEFAULT 0 NOT NULL,
				block_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
				block_icon VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
				block_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
				block_text_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
				block_text_options INTEGER DEFAULT 7 NOT NULL,
				block_text_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL
			);",

			"ALTER TABLE {$table_prefix}express_blocks ADD PRIMARY KEY (block_id);",

			"CREATE INDEX {$table_prefix}express_blocks_block_order ON {$table_prefix}express_blocks(block_order);",

			"CREATE GENERATOR {$table_prefix}express_blocks_gen;",

			"SET GENERATOR {$table_prefix}express_blocks_gen TO 0;",

			"CREATE TRIGGER t_{$table_prefix}express_blocks FOR {$table_prefix}express_blocks
			BEFORE INSERT
			AS
			BEGIN
				NEW.block_id = GEN_ID({$table_prefix}express_blocks_gen, 1);
			END;",

			"CREATE TABLE {$table_prefix}express_links (
				link_id INTEGER NOT NULL,
				link_title VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
				link_is_cat INTEGER DEFAULT 0 NOT NULL,
				link_url VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
				link_icon VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
				link_order INTEGER DEFAULT 0 NOT NULL
			);",

			"ALTER TABLE {$table_prefix}express_links ADD PRIMARY KEY (link_id);",

			"CREATE INDEX {$table_prefix}express_links_link_order ON {$table_prefix}express_links(link_order);",

			"CREATE GENERATOR {$table_prefix}express_links_gen",

			"SET GENERATOR {$table_prefix}express_links_gen TO 0;",

			"CREATE TRIGGER t_{$table_prefix}express_links FOR {$table_prefix}express_links
			BEFORE INSERT
			AS
			BEGIN
				NEW.link_id = GEN_ID({$table_prefix}express_links_gen, 1);
			END;",

			"CREATE TABLE {$table_prefix}express_ads (
				ads_id INTEGER NOT NULL,
				ads_title VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
				ads_url VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
				ads_image VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
				ads_width INTEGER DEFAULT 0 NOT NULL,
				ads_height INTEGER DEFAULT 0 NOT NULL,
				ads_order INTEGER DEFAULT 0 NOT NULL,
				ads_display INTEGER DEFAULT 1 NOT NULL,
				ads_clicks INTEGER DEFAULT 0 NOT NULL,
				ads_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL
			);",

			"ALTER TABLE {$table_prefix}express_ads ADD PRIMARY KEY (ads_id)",

			"CREATE INDEX {$table_prefix}express_ads_ads_display ON {$table_prefix}express_ads(ads_display);",

			"CREATE INDEX {$table_prefix}express_ads_ads_order ON {$table_prefix}express_ads(ads_order);",

			"CREATE GENERATOR {$table_prefix}express_ads_gen;",

			"SET GENERATOR {$table_prefix}express_ads_gen TO 0;",

			"CREATE TRIGGER t_{$table_prefix}express_ads FOR {$table_prefix}express_ads
			BEFORE INSERT
			AS
			BEGIN
				NEW.ads_id = GEN_ID({$table_prefix}express_ads_gen, 1);
			END;",

			"CREATE TABLE {$table_prefix}express_rates (
				rate_id INTEGER NOT NULL,
				article_id INTEGER DEFAULT 0 NOT NULL,
				user_id INTEGER DEFAULT 0 NOT NULL,
				user_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL,
				rates INTEGER DEFAULT 0 NOT NULL
			);",

			"ALTER TABLE {$table_prefix}express_rates ADD PRIMARY KEY (rate_id);",

			"CREATE GENERATOR {$table_prefix}express_rates_gen;",

			"SET GENERATOR {$table_prefix}express_rates_gen TO 0;",

			"CREATE TRIGGER t_{$table_prefix}express_rates FOR {$table_prefix}express_rates
			BEFORE INSERT
			AS
			BEGIN
				NEW.rate_id = GEN_ID({$table_prefix}express_rates_gen, 1);
			END;",

			"CREATE TABLE {$table_prefix}express_comments (
				comment_id INTEGER NOT NULL,
				article_id INTEGER DEFAULT 0 NOT NULL,
				poster_id INTEGER DEFAULT 0 NOT NULL,
				poster_username VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
				poster_colour VARCHAR(6) CHARACTER SET NONE DEFAULT '' NOT NULL,
				poster_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL,
				comment BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,
				comment_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
				comment_options INTEGER DEFAULT 7 NOT NULL,
				comment_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL,
				comment_time INTEGER DEFAULT 0 NOT NULL
			);",

			"ALTER TABLE {$table_prefix}express_comments ADD PRIMARY KEY (comment_id);",

			"CREATE GENERATOR {$table_prefix}express_comments_gen;",

			"SET GENERATOR {$table_prefix}express_comments_gen TO 0;",

			"CREATE TRIGGER t_{$table_prefix}express_comments FOR {$table_prefix}express_comments
			BEFORE INSERT
			AS
			BEGIN
				NEW.comment_id = GEN_ID({$table_prefix}express_comments_gen, 1);
			END;",
		);
	break;

	case 'mssql':
		$sql_ary = array(
			"CREATE TABLE [{$table_prefix}express_categories] (
				[cat_id] [int] IDENTITY (1, 1) NOT NULL ,
				[cat_name] [varchar] (255) DEFAULT ('') NOT NULL ,
				[cat_order] [int] DEFAULT (0) NOT NULL ,
				[cat_icon] [varchar] (255) DEFAULT ('') NOT NULL ,
				[cat_articles] [int] DEFAULT (0) NOT NULL ,
				[cat_desc] [varchar] (255) DEFAULT ('') NOT NULL ,
				[display_on_index] [int] DEFAULT (1) NOT NULL 
			) ON [PRIMARY]",

			"ALTER TABLE [{$table_prefix}express_categories] WITH NOCHECK ADD 
				CONSTRAINT [PK_{$table_prefix}express_categories] PRIMARY KEY  CLUSTERED 
				(
					[cat_id]
				)  ON [PRIMARY]",

			"CREATE  INDEX [cat_order] ON [{$table_prefix}express_categories]([cat_order]) ON [PRIMARY]",

			"CREATE TABLE [{$table_prefix}express_articles] (
				[article_id] [int] IDENTITY (1, 1) NOT NULL ,
				[article_cat] [int] DEFAULT (0) NOT NULL ,
				[article_title] [varchar] (255) DEFAULT ('') NOT NULL ,
				[article_intro] [text] DEFAULT ('') NOT NULL ,
				[article_content] [text] DEFAULT ('') NOT NULL ,
				[article_content_bitfield] [varchar] (255) DEFAULT ('') NOT NULL ,
				[article_content_options] [int] DEFAULT (7) NOT NULL ,
				[article_content_uid] [varchar] (8) DEFAULT ('') NOT NULL ,
				[article_views] [int] DEFAULT (0) NOT NULL ,
				[article_rates] [int] DEFAULT (0) NOT NULL ,
				[article_ratings] [int] DEFAULT (0) NOT NULL ,
				[article_comments] [int] DEFAULT (0) NOT NULL ,
				[article_image] [varchar] (255) DEFAULT ('') NOT NULL ,
				[article_similar] [varchar] (255) DEFAULT ('') NOT NULL ,
				[article_source] [varchar] (255) DEFAULT ('') NOT NULL ,
				[article_time] [int] DEFAULT (0) NOT NULL 
			) ON [PRIMARY]",

			"ALTER TABLE [{$table_prefix}express_articles] WITH NOCHECK ADD 
				CONSTRAINT [PK_{$table_prefix}express_articles] PRIMARY KEY  CLUSTERED 
				(
					[article_id]
				)  ON [PRIMARY]",

			"CREATE TABLE [{$table_prefix}express_pages] (
				[page_id] [int] IDENTITY (1, 1) NOT NULL ,
				[page_basename] [varchar] (40) DEFAULT ('') NOT NULL ,
				[page_name] [varchar] (255) DEFAULT ('') NOT NULL ,
				[page_custom] [int] DEFAULT (0) NOT NULL ,
				[page_order] [int] DEFAULT (0) NOT NULL ,
				[page_icon] [varchar] (255) DEFAULT ('') NOT NULL ,
				[page_views] [int] DEFAULT (0) NOT NULL ,
				[page_content] [text] DEFAULT ('') NOT NULL ,
				[page_content_bitfield] [varchar] (255) DEFAULT ('') NOT NULL ,
				[page_content_options] [int] DEFAULT (7) NOT NULL ,
				[page_content_uid] [varchar] (8) DEFAULT ('') NOT NULL ,
				[page_time] [int] DEFAULT (0) NOT NULL ,
				[template_file] [varchar] (255) DEFAULT ('') NOT NULL ,
				[language_file] [varchar] (255) DEFAULT ('') NOT NULL 
			) ON [PRIMARY]",

			"ALTER TABLE [{$table_prefix}express_pages] WITH NOCHECK ADD 
				CONSTRAINT [PK_{$table_prefix}express_pages] PRIMARY KEY  CLUSTERED 
				(
					[page_id]
				)  ON [PRIMARY]",

			"CREATE TABLE [{$table_prefix}express_blocks] (
				[block_id] [int] IDENTITY (1, 1) NOT NULL ,
				[block_title] [varchar] (255) DEFAULT ('') NOT NULL ,
				[block_type] [varchar] (40) DEFAULT ('') NOT NULL ,
				[block_position] [int] DEFAULT (0) NOT NULL ,
				[block_order] [int] DEFAULT (0) NOT NULL ,
				[block_icon] [varchar] (255) DEFAULT ('') NOT NULL ,
				[block_text] [text] DEFAULT ('') NOT NULL ,
				[block_text_bitfield] [varchar] (255) DEFAULT ('') NOT NULL ,
				[block_text_options] [int] DEFAULT (7) NOT NULL ,
				[block_text_uid] [varchar] (8) DEFAULT ('') NOT NULL 
			) ON [PRIMARY]",

			"CREATE  INDEX [page_order] ON [{$table_prefix}express_pages]([page_order]) ON [PRIMARY]",

			"ALTER TABLE [{$table_prefix}express_blocks] WITH NOCHECK ADD 
				CONSTRAINT [PK_{$table_prefix}express_blocks] PRIMARY KEY  CLUSTERED 
				(
					[block_id]
				)  ON [PRIMARY]",

			"CREATE  INDEX [block_order] ON [{$table_prefix}express_blocks]([block_order]) ON [PRIMARY]",

			"CREATE TABLE [{$table_prefix}express_links] (
				[link_id] [int] IDENTITY (1, 1) NOT NULL ,
				[link_title] [varchar] (255) DEFAULT ('') NOT NULL ,
				[link_is_cat] [int] DEFAULT (0) NOT NULL ,
				[link_url] [varchar] (255) DEFAULT ('') NOT NULL ,
				[link_icon] [varchar] (255) DEFAULT ('') NOT NULL ,
				[link_order] [int] DEFAULT (0) NOT NULL 
			) ON [PRIMARY]",

			"ALTER TABLE [{$table_prefix}express_links] WITH NOCHECK ADD 
				CONSTRAINT [PK_{$table_prefix}express_links] PRIMARY KEY  CLUSTERED 
				(
					[link_id]
				)  ON [PRIMARY]",

			"CREATE  INDEX [link_order] ON [{$table_prefix}express_links]([link_order]) ON [PRIMARY]",

			"CREATE TABLE [{$table_prefix}express_ads] (
				[ads_id] [int] IDENTITY (1, 1) NOT NULL ,
				[ads_title] [varchar] (255) DEFAULT ('') NOT NULL ,
				[ads_url] [varchar] (255) DEFAULT ('') NOT NULL ,
				[ads_image] [varchar] (255) DEFAULT ('') NOT NULL ,
				[ads_width] [int] DEFAULT (0) NOT NULL ,
				[ads_height] [int] DEFAULT (0) NOT NULL ,
				[ads_order] [int] DEFAULT (0) NOT NULL ,
				[ads_display] [int] DEFAULT (1) NOT NULL ,
				[ads_clicks] [int] DEFAULT (0) NOT NULL ,
				[ads_text] [text] DEFAULT ('') NOT NULL 
			) ON [PRIMARY]",

			"ALTER TABLE [{$table_prefix}express_ads] WITH NOCHECK ADD 
				CONSTRAINT [PK_{$table_prefix}express_ads] PRIMARY KEY  CLUSTERED 
				(
					[ads_id]
				)  ON [PRIMARY]",

			"CREATE  INDEX [ads_display] ON [{$table_prefix}express_ads]([ads_display]) ON [PRIMARY]",

			"CREATE  INDEX [ads_order] ON [{$table_prefix}express_ads]([ads_order]) ON [PRIMARY]",

			"CREATE TABLE [{$table_prefix}express_rates] (
				[rate_id] [int] IDENTITY (1, 1) NOT NULL ,
				[article_id] [int] DEFAULT (0) NOT NULL ,
				[user_id] [int] DEFAULT (0) NOT NULL ,
				[user_ip] [varchar] (40) DEFAULT ('') NOT NULL ,
				[rates] [int] DEFAULT (0) NOT NULL 
			) ON [PRIMARY]",

			"ALTER TABLE [{$table_prefix}express_rates] WITH NOCHECK ADD 
				CONSTRAINT [PK_{$table_prefix}express_rates] PRIMARY KEY  CLUSTERED 
				(
					[rate_id]
				)  ON [PRIMARY]",

			"CREATE TABLE [{$table_prefix}express_comments] (
				[comment_id] [int] IDENTITY (1, 1) NOT NULL ,
				[article_id] [int] DEFAULT (0) NOT NULL ,
				[poster_id] [int] DEFAULT (0) NOT NULL ,
				[poster_username] [varchar] (255) DEFAULT ('') NOT NULL ,
				[poster_colour] [varchar] (6) DEFAULT ('') NOT NULL ,
				[poster_ip] [varchar] (40) DEFAULT ('') NOT NULL ,
				[comment] [text] DEFAULT ('') NOT NULL ,
				[comment_bitfield] [varchar] (255) DEFAULT ('') NOT NULL ,
				[comment_options] [int] DEFAULT (7) NOT NULL ,
				[comment_uid] [varchar] (8) DEFAULT ('') NOT NULL ,
				[comment_time] [int] DEFAULT (0) NOT NULL 
			) ON [PRIMARY]",

			"ALTER TABLE [{$table_prefix}express_comments] WITH NOCHECK ADD 
				CONSTRAINT [PK_{$table_prefix}express_comments] PRIMARY KEY  CLUSTERED 
				(
					[comment_id]
				)  ON [PRIMARY]",
		);
	break;

	case 'oracle':
		$sql_ary = array(
			"CREATE TABLE {$table_prefix}express_categories (
				cat_id number(8) NOT NULL,
				cat_name varchar2(765) DEFAULT '' ,
				cat_order number(8) DEFAULT '0' NOT NULL,
				cat_icon varchar2(255) DEFAULT '' ,
				cat_articles number(8) DEFAULT '0' NOT NULL,
				cat_desc varchar2(765) DEFAULT '' ,
				display_on_index number(1) DEFAULT '1' NOT NULL,
				CONSTRAINT pk_{$table_prefix}express_categories PRIMARY KEY (cat_id)
			)",

			"CREATE INDEX {$table_prefix}express_categories_cat_order ON {$table_prefix}express_categories (cat_order)",

			"CREATE SEQUENCE {$table_prefix}express_categories_seq",

			"CREATE OR REPLACE TRIGGER t_{$table_prefix}express_categories
			BEFORE INSERT ON {$table_prefix}express_categories
			FOR EACH ROW WHEN (
				new.cat_id IS NULL OR new.cat_id = 0
			)
			BEGIN
				SELECT {$table_prefix}express_categories_seq.nextval
				INTO :new.cat_id
				FROM dual;
			END;",

			"CREATE TABLE {$table_prefix}express_articles (
				article_id number(8) NOT NULL,
				article_cat number(8) DEFAULT '0' NOT NULL,
				article_title varchar2(765) DEFAULT '' ,
				article_intro clob DEFAULT '' ,
				article_content clob DEFAULT '' ,
				article_content_bitfield varchar2(255) DEFAULT '' ,
				article_content_options number(11) DEFAULT '7' NOT NULL,
				article_content_uid varchar2(8) DEFAULT '' ,
				article_views number(8) DEFAULT '0' NOT NULL,
				article_rates number(2) DEFAULT '0' NOT NULL,
				article_ratings number(8) DEFAULT '0' NOT NULL,
				article_comments number(8) DEFAULT '0' NOT NULL,
				article_image varchar2(255) DEFAULT '' ,
				article_similar varchar2(255) DEFAULT '' ,
				article_source varchar2(765) DEFAULT '' ,
				article_time number(11) DEFAULT '0' NOT NULL,
				CONSTRAINT pk_{$table_prefix}express_articles PRIMARY KEY (article_id)
			)",

			"CREATE SEQUENCE {$table_prefix}express_articles_seq",

			"CREATE OR REPLACE TRIGGER t_{$table_prefix}express_articles
			BEFORE INSERT ON {$table_prefix}express_articles
			FOR EACH ROW WHEN (
				new.article_id IS NULL OR new.article_id = 0
			)
			BEGIN
				SELECT {$table_prefix}express_articles_seq.nextval
				INTO :new.article_id
				FROM dual;
			END;",

			"CREATE TABLE {$table_prefix}express_pages (
				page_id number(8) NOT NULL,
				page_basename varchar2(40) DEFAULT '' ,
				page_name varchar2(765) DEFAULT '' ,
				page_custom number(1) DEFAULT '0' NOT NULL,
				page_order number(8) DEFAULT '0' NOT NULL,
				page_icon varchar2(255) DEFAULT '' ,
				page_views number(8) DEFAULT '0' NOT NULL,
				page_content clob DEFAULT '' ,
				page_content_bitfield varchar2(255) DEFAULT '' ,
				page_content_options number(11) DEFAULT '7' NOT NULL,
				page_content_uid varchar2(8) DEFAULT '' ,
				page_time number(11) DEFAULT '0' NOT NULL,
				template_file varchar2(255) DEFAULT '' ,
				language_file varchar2(255) DEFAULT '' ,
				CONSTRAINT pk_{$table_prefix}express_pages PRIMARY KEY (page_id)
			)",

			"CREATE INDEX {$table_prefix}express_pages_page_order ON {$table_prefix}express_pages (page_order)",

			"CREATE SEQUENCE {$table_prefix}express_pages_seq",

			"CREATE OR REPLACE TRIGGER t_{$table_prefix}express_pages
			BEFORE INSERT ON {$table_prefix}express_pages
			FOR EACH ROW WHEN (
				new.page_id IS NULL OR new.page_id = 0
			)
			BEGIN
				SELECT {$table_prefix}express_pages_seq.nextval
				INTO :new.page_id
				FROM dual;
			END;",

			"CREATE TABLE {$table_prefix}express_blocks (
				block_id number(8) NOT NULL,
				block_title varchar2(765) DEFAULT '' ,
				block_type varchar2(40) DEFAULT '' ,
				block_position number(1) DEFAULT '0' NOT NULL,
				block_order number(8) DEFAULT '0' NOT NULL,
				block_icon varchar2(255) DEFAULT '' ,
				block_text clob DEFAULT '' ,
				block_text_bitfield varchar2(255) DEFAULT '' ,
				block_text_options number(11) DEFAULT '7' NOT NULL,
				block_text_uid varchar2(8) DEFAULT '' ,
				CONSTRAINT pk_{$table_prefix}express_blocks PRIMARY KEY (block_id)
			)",

			"CREATE INDEX {$table_prefix}express_blocks_block_order ON {$table_prefix}express_blocks (block_order)",

			"CREATE SEQUENCE {$table_prefix}express_blocks_seq",

			"CREATE OR REPLACE TRIGGER t_{$table_prefix}express_blocks
			BEFORE INSERT ON {$table_prefix}express_blocks
			FOR EACH ROW WHEN (
				new.block_id IS NULL OR new.block_id = 0
			)
			BEGIN
				SELECT {$table_prefix}express_blocks_seq.nextval
				INTO :new.block_id
				FROM dual;
			END;",

			"CREATE TABLE {$table_prefix}express_links (
				link_id number(8) NOT NULL,
				link_title varchar2(765) DEFAULT '' ,
				link_is_cat number(1) DEFAULT '0' NOT NULL,
				link_url varchar2(255) DEFAULT '' ,
				link_icon varchar2(255) DEFAULT '' ,
				link_order number(8) DEFAULT '0' NOT NULL,
				CONSTRAINT pk_{$table_prefix}express_links PRIMARY KEY (link_id)
			)",

			"CREATE INDEX {$table_prefix}express_links_link_order ON {$table_prefix}express_links (link_order)",

			"CREATE SEQUENCE {$table_prefix}express_links_seq",

			"CREATE OR REPLACE TRIGGER t_{$table_prefix}express_links
			BEFORE INSERT ON {$table_prefix}express_links
			FOR EACH ROW WHEN (
				new.link_id IS NULL OR new.link_id = 0
			)
			BEGIN
				SELECT {$table_prefix}express_links_seq.nextval
				INTO :new.link_id
				FROM dual;
			END;",

			"CREATE TABLE {$table_prefix}express_ads (
				ads_id number(8) NOT NULL,
				ads_title varchar2(765) DEFAULT '' ,
				ads_url varchar2(255) DEFAULT '' ,
				ads_image varchar2(255) DEFAULT '' ,
				ads_width number(4) DEFAULT '0' NOT NULL,
				ads_height number(4) DEFAULT '0' NOT NULL,
				ads_order number(8) DEFAULT '0' NOT NULL,
				ads_display number(1) DEFAULT '1' NOT NULL,
				ads_clicks number(8) DEFAULT '0' NOT NULL,
				ads_text clob DEFAULT '' ,
				CONSTRAINT pk_{$table_prefix}express_ads PRIMARY KEY (ads_id)
			)",

			"CREATE INDEX {$table_prefix}express_ads_ads_display ON {$table_prefix}express_ads (ads_display)",

			"CREATE INDEX {$table_prefix}express_ads_ads_order ON {$table_prefix}express_ads (ads_order)",

			"CREATE SEQUENCE {$table_prefix}express_ads_seq",

			"CREATE OR REPLACE TRIGGER t_{$table_prefix}express_ads
			BEFORE INSERT ON {$table_prefix}express_ads
			FOR EACH ROW WHEN (
				new.ads_id IS NULL OR new.ads_id = 0
			)
			BEGIN
				SELECT {$table_prefix}express_ads_seq.nextval
				INTO :new.ads_id
				FROM dual;
			END;",

			"CREATE TABLE {$table_prefix}express_rates (
				rate_id number(8) NOT NULL,
				article_id number(8) DEFAULT '0' NOT NULL,
				user_id number(8) DEFAULT '0' NOT NULL,
				user_ip varchar2(40) DEFAULT '' ,
				rates number(2) DEFAULT '0' NOT NULL,
				CONSTRAINT pk_{$table_prefix}express_rates PRIMARY KEY (rate_id)
			)",

			"CREATE SEQUENCE {$table_prefix}express_rates_seq",

			"CREATE OR REPLACE TRIGGER t_{$table_prefix}express_rates
			BEFORE INSERT ON {$table_prefix}express_rates
			FOR EACH ROW WHEN (
				new.rate_id IS NULL OR new.rate_id = 0
			)
			BEGIN
				SELECT {$table_prefix}express_rates_seq.nextval
				INTO :new.rate_id
				FROM dual;
			END;",

			"CREATE TABLE {$table_prefix}express_comments (
				comment_id number(8) NOT NULL,
				article_id number(8) DEFAULT '0' NOT NULL,
				poster_id number(8) DEFAULT '0' NOT NULL,
				poster_username varchar2(255) DEFAULT '' ,
				poster_colour varchar2(6) DEFAULT '' ,
				poster_ip varchar2(40) DEFAULT '' ,
				comment clob DEFAULT '' ,
				comment_bitfield varchar2(255) DEFAULT '' ,
				comment_options number(11) DEFAULT '7' NOT NULL,
				comment_uid varchar2(8) DEFAULT '' ,
				comment_time number(11) DEFAULT '0' NOT NULL,
				CONSTRAINT pk_{$table_prefix}express_comments PRIMARY KEY (comment_id)
			)",

			"CREATE SEQUENCE {$table_prefix}express_comments_seq",

			"CREATE OR REPLACE TRIGGER t_{$table_prefix}express_comments
			BEFORE INSERT ON {$table_prefix}express_comments
			FOR EACH ROW WHEN (
				new.comment_id IS NULL OR new.comment_id = 0
			)
			BEGIN
				SELECT {$table_prefix}express_comments_seq.nextval
				INTO :new.comment_id
				FROM dual;
			END;",
		);
	break;

	case 'postgres':
		$sql_ary = array(
			"CREATE SEQUENCE {$table_prefix}express_categories_seq;",

			"CREATE TABLE {$table_prefix}express_categories (
				cat_id INT4 DEFAULT nextval('{$table_prefix}express_categories_seq'),
				cat_name varchar(255) DEFAULT '' NOT NULL,
				cat_order INT4 DEFAULT '0' NOT NULL CHECK (cat_order >= 0),
				cat_icon varchar(255) DEFAULT '' NOT NULL,
				cat_articles INT4 DEFAULT '0' NOT NULL CHECK (cat_articles >= 0),
				cat_desc varchar(255) DEFAULT '' NOT NULL,
				display_on_index INT2 DEFAULT '1' NOT NULL CHECK (display_on_index >= 0),
				PRIMARY KEY (cat_id)
			);",

			"CREATE INDEX {$table_prefix}express_categories_cat_order ON {$table_prefix}express_categories (cat_order);",

			"CREATE SEQUENCE {$table_prefix}express_articles_seq;",

			"CREATE TABLE {$table_prefix}express_articles (
				article_id INT4 DEFAULT nextval('{$table_prefix}express_articles_seq'),
				article_cat INT4 DEFAULT '0' NOT NULL CHECK (article_cat >= 0),
				article_title varchar(255) DEFAULT '' NOT NULL,
				article_intro TEXT DEFAULT '' NOT NULL,
				article_content TEXT DEFAULT '' NOT NULL,
				article_content_bitfield varchar(255) DEFAULT '' NOT NULL,
				article_content_options INT4 DEFAULT '7' NOT NULL CHECK (article_content_options >= 0),
				article_content_uid varchar(8) DEFAULT '' NOT NULL,
				article_views INT4 DEFAULT '0' NOT NULL CHECK (article_views >= 0),
				article_rates INT2 DEFAULT '0' NOT NULL CHECK (article_rates >= 0),
				article_ratings INT4 DEFAULT '0' NOT NULL CHECK (article_ratings >= 0),
				article_comments INT4 DEFAULT '0' NOT NULL CHECK (article_comments >= 0),
				article_image varchar(255) DEFAULT '' NOT NULL,
				article_similar varchar(255) DEFAULT '' NOT NULL,
				article_source varchar(255) DEFAULT '' NOT NULL,
				article_time INT4 DEFAULT '0' NOT NULL CHECK (article_time >= 0),
				PRIMARY KEY (article_id)
			);",

			"CREATE SEQUENCE {$table_prefix}express_pages_seq;",

			"CREATE TABLE {$table_prefix}express_pages (
				page_id INT4 DEFAULT nextval('{$table_prefix}express_pages_seq'),
				page_basename varchar(40) DEFAULT '' NOT NULL,
				page_name varchar(255) DEFAULT '' NOT NULL,
				page_custom INT2 DEFAULT '0' NOT NULL CHECK (page_custom >= 0),
				page_order INT4 DEFAULT '0' NOT NULL CHECK (page_order >= 0),
				page_icon varchar(255) DEFAULT '' NOT NULL,
				page_views INT4 DEFAULT '0' NOT NULL CHECK (page_views >= 0),
				page_content TEXT DEFAULT '' NOT NULL,
				page_content_bitfield varchar(255) DEFAULT '' NOT NULL,
				page_content_options INT4 DEFAULT '7' NOT NULL CHECK (page_content_options >= 0),
				page_content_uid varchar(8) DEFAULT '' NOT NULL,
				page_time INT4 DEFAULT '0' NOT NULL CHECK (page_time >= 0),
				template_file varchar(255) DEFAULT '' NOT NULL,
				language_file varchar(255) DEFAULT '' NOT NULL,
				PRIMARY KEY (page_id)
			);",

			"CREATE INDEX {$table_prefix}express_pages_page_order ON {$table_prefix}express_pages (page_order);",

			"CREATE SEQUENCE {$table_prefix}express_blocks_seq;",

			"CREATE TABLE {$table_prefix}express_blocks (
				block_id INT4 DEFAULT nextval('{$table_prefix}express_blocks_seq'),
				block_title varchar(255) DEFAULT '' NOT NULL,
				block_type varchar(40) DEFAULT '' NOT NULL,
				block_position INT2 DEFAULT '0' NOT NULL CHECK (block_position >= 0),
				block_order INT4 DEFAULT '0' NOT NULL CHECK (block_order >= 0),
				block_icon varchar(255) DEFAULT '' NOT NULL,
				block_text TEXT DEFAULT '' NOT NULL,
				block_text_bitfield varchar(255) DEFAULT '' NOT NULL,
				block_text_options INT4 DEFAULT '7' NOT NULL CHECK (block_text_options >= 0),
				block_text_uid varchar(8) DEFAULT '' NOT NULL,
				PRIMARY KEY (block_id)
			);",

			"CREATE INDEX {$table_prefix}express_blocks_block_order ON {$table_prefix}express_blocks (block_order);",

			"CREATE SEQUENCE {$table_prefix}express_links_seq;",

			"CREATE TABLE {$table_prefix}express_links (
				link_id INT4 DEFAULT nextval('{$table_prefix}express_links_seq'),
				link_title varchar(255) DEFAULT '' NOT NULL,
				link_is_cat INT2 DEFAULT '0' NOT NULL CHECK (link_is_cat >= 0),
				link_url varchar(255) DEFAULT '' NOT NULL,
				link_icon varchar(255) DEFAULT '' NOT NULL,
				link_order INT4 DEFAULT '0' NOT NULL CHECK (link_order >= 0),
				PRIMARY KEY (link_id)
			);",

			"CREATE INDEX {$table_prefix}express_links_link_order ON {$table_prefix}express_links (link_order);",

			"CREATE SEQUENCE {$table_prefix}express_ads_seq;",

			"CREATE TABLE {$table_prefix}express_ads (
				ads_id INT4 DEFAULT nextval('{$table_prefix}express_ads_seq'),
				ads_title varchar(255) DEFAULT '' NOT NULL,
				ads_url varchar(255) DEFAULT '' NOT NULL,
				ads_image varchar(255) DEFAULT '' NOT NULL,
				ads_width INT2 DEFAULT '0' NOT NULL,
				ads_height INT2 DEFAULT '0' NOT NULL,
				ads_order INT4 DEFAULT '0' NOT NULL CHECK (ads_order >= 0),
				ads_display INT2 DEFAULT '1' NOT NULL CHECK (ads_display >= 0),
				ads_clicks INT4 DEFAULT '0' NOT NULL CHECK (ads_clicks >= 0),
				ads_text TEXT DEFAULT '' NOT NULL,
				PRIMARY KEY (ads_id)
			);",

			"CREATE INDEX {$table_prefix}express_ads_ads_display ON {$table_prefix}express_ads (ads_display);",

			"CREATE INDEX {$table_prefix}express_ads_ads_order ON {$table_prefix}express_ads (ads_order);",

			"CREATE SEQUENCE {$table_prefix}express_rates_seq;",

			"CREATE TABLE {$table_prefix}express_rates (
				rate_id INT4 DEFAULT nextval('{$table_prefix}express_rates_seq'),
				article_id INT4 DEFAULT '0' NOT NULL CHECK (article_id >= 0),
				user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0),
				user_ip varchar(40) DEFAULT '' NOT NULL,
				rates INT2 DEFAULT '0' NOT NULL CHECK (rates >= 0),
				PRIMARY KEY (rate_id)
			);",

			"CREATE SEQUENCE {$table_prefix}express_comments_seq;",

			"CREATE TABLE {$table_prefix}express_comments (
				comment_id INT4 DEFAULT nextval('{$table_prefix}express_comments_seq'),
				article_id INT4 DEFAULT '0' NOT NULL CHECK (article_id >= 0),
				poster_id INT4 DEFAULT '0' NOT NULL CHECK (poster_id >= 0),
				poster_username varchar(255) DEFAULT '' NOT NULL,
				poster_colour varchar(6) DEFAULT '' NOT NULL,
				poster_ip varchar(40) DEFAULT '' NOT NULL,
				comment TEXT DEFAULT '' NOT NULL,
				comment_bitfield varchar(255) DEFAULT '' NOT NULL,
				comment_options INT4 DEFAULT '7' NOT NULL CHECK (comment_options >= 0),
				comment_uid varchar(8) DEFAULT '' NOT NULL,
				comment_time INT4 DEFAULT '0' NOT NULL CHECK (comment_time >= 0),
				PRIMARY KEY (comment_id)
			);",
		);
	break;

	case 'sqlite':
		$sql_ary = array(
			"CREATE TABLE {$table_prefix}express_categories (
				cat_id INTEGER PRIMARY KEY NOT NULL ,
				cat_name text(65535) NOT NULL DEFAULT '',
				cat_order INTEGER UNSIGNED NOT NULL DEFAULT '0',
				cat_icon varchar(255) NOT NULL DEFAULT '',
				cat_articles INTEGER UNSIGNED NOT NULL DEFAULT '0',
				cat_desc text(65535) NOT NULL DEFAULT '',
				display_on_index INTEGER UNSIGNED NOT NULL DEFAULT '1'
			);",

			"CREATE INDEX {$table_prefix}express_categories_cat_order ON {$table_prefix}express_categories (cat_order);",

			"CREATE TABLE {$table_prefix}express_articles (
				article_id INTEGER PRIMARY KEY NOT NULL ,
				article_cat INTEGER UNSIGNED NOT NULL DEFAULT '0',
				article_title text(65535) NOT NULL DEFAULT '',
				article_intro mediumtext(16777215) NOT NULL DEFAULT ''L,
				article_content mediumtext(16777215) NOT NULL DEFAULT ''L,
				article_content_bitfield varchar(255) NOT NULL DEFAULT '',
				article_content_options INTEGER UNSIGNED NOT NULL DEFAULT '7',
				article_content_uid varchar(8) NOT NULL DEFAULT '',
				article_views INTEGER UNSIGNED NOT NULL DEFAULT '0',
				article_rates INTEGER UNSIGNED NOT NULL DEFAULT '0',
				article_ratings INTEGER UNSIGNED NOT NULL DEFAULT '0',
				article_comments INTEGER UNSIGNED NOT NULL DEFAULT '0',
				article_image varbinary(255) DEFAULT '' NOT NULL,
				article_similar varchar(255) NOT NULL DEFAULT '',
				article_source text(65535) NOT NULL DEFAULT '',
				article_time INTEGER UNSIGNED NOT NULL DEFAULT '0'
			);",

			"CREATE TABLE {$table_prefix}express_pages (
				page_id INTEGER PRIMARY KEY NOT NULL ,
				page_basename varchar(40) NOT NULL DEFAULT '',
				page_name text(65535) NOT NULL DEFAULT '',
				page_custom INTEGER UNSIGNED NOT NULL DEFAULT '0',
				page_order INTEGER UNSIGNED NOT NULL DEFAULT '0',
				page_icon varchar(255) NOT NULL DEFAULT '',
				page_views INTEGER UNSIGNED NOT NULL DEFAULT '0',
				page_content mediumtext(16777215) NOT NULL DEFAULT ''L,
				page_content_bitfield varchar(255) NOT NULL DEFAULT '',
				page_content_options INTEGER UNSIGNED NOT NULL DEFAULT '7',
				page_content_uid varchar(8) NOT NULL DEFAULT '',
				page_time INTEGER UNSIGNED NOT NULL DEFAULT '0',
				template_file varchar(255) NOT NULL DEFAULT '',
				language_file varchar(255) NOT NULL DEFAULT ''
			);",

			"CREATE INDEX {$table_prefix}express_pages_page_order ON {$table_prefix}express_pages (page_order);",

			"CREATE TABLE {$table_prefix}express_blocks (
				block_id INTEGER PRIMARY KEY NOT NULL ,
				block_title varchar(255) NOT NULL DEFAULT '',
				block_type varchar(40) NOT NULL DEFAULT '',
				block_position INTEGER UNSIGNED NOT NULL DEFAULT '0',
				block_order INTEGER UNSIGNED NOT NULL DEFAULT '0',
				block_icon varchar(255) NOT NULL DEFAULT '',
				block_text mediumtext(16777215) NOT NULL DEFAULT ''L,
				block_text_bitfield varchar(255) NOT NULL DEFAULT '',
				block_text_options INTEGER UNSIGNED NOT NULL DEFAULT '7',
				block_text_uid varchar(8) NOT NULL DEFAULT ''
			);",

			"CREATE INDEX {$table_prefix}express_blocks_block_order ON {$table_prefix}express_blocks (block_order);",

			"CREATE TABLE {$table_prefix}express_links (
				link_id INTEGER PRIMARY KEY NOT NULL ,
				link_title varchar(255) NOT NULL DEFAULT '',
				link_is_cat INTEGER UNSIGNED NOT NULL DEFAULT '0',
				link_url varchar(255) NOT NULL DEFAULT '',
				link_icon varchar(255) NOT NULL DEFAULT '',
				link_order INTEGER UNSIGNED NOT NULL DEFAULT '0'
			);",

			"CREATE INDEX {$table_prefix}express_links_link_order ON {$table_prefix}express_links (link_order);",

			"CREATE TABLE {$table_prefix}express_ads (
				ads_id INTEGER PRIMARY KEY NOT NULL ,
				ads_title varchar(255) NOT NULL DEFAULT '',
				ads_url varchar(255) NOT NULL DEFAULT '',
				ads_image varchar(255) NOT NULL DEFAULT '',
				ads_width INTEGER UNSIGNED NOT NULL DEFAULT '0',
				ads_height INTEGER UNSIGNED NOT NULL DEFAULT '0',
				ads_order INTEGER UNSIGNED NOT NULL DEFAULT '0',
				ads_display INTEGER UNSIGNED NOT NULL DEFAULT '1',
				ads_clicks INTEGER UNSIGNED NOT NULL DEFAULT '0',
				ads_text mediumtext(16777215) NOT NULL DEFAULT ''L
			);",

			"CREATE INDEX {$table_prefix}express_ads_ads_display ON {$table_prefix}express_ads (ads_display);",

			"CREATE INDEX {$table_prefix}express_ads_ads_order ON {$table_prefix}express_ads (ads_order)",

			"CREATE TABLE {$table_prefix}express_rates (
				rate_id INTEGER PRIMARY KEY NOT NULL ,
				article_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
				user_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
				user_ip varchar(40) NOT NULL DEFAULT '',
				rates INTEGER UNSIGNED NOT NULL DEFAULT '0'
			);",

			"CREATE TABLE {$table_prefix}express_comments (
				comment_id INTEGER PRIMARY KEY NOT NULL ,
				article_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
				poster_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
				poster_username varchar(255) NOT NULL DEFAULT '',
				poster_colour varchar(6) NOT NULL DEFAULT '',
				poster_ip varchar(40) NOT NULL DEFAULT '',
				comment mediumtext(16777215) NOT NULL DEFAULT ''L,
				comment_bitfield varchar(255) NOT NULL DEFAULT '',
				comment_options INTEGER UNSIGNED NOT NULL DEFAULT '7',
				comment_uid varchar(8) NOT NULL DEFAULT '',
				comment_time INTEGER UNSIGNED NOT NULL DEFAULT '0'
			);",
		);
	break;

	default:
		if ($dbms == 'mysql' && version_compare($db->mysql_version, '4.1.3', '>='))
		{
			$sql_ary = array(
				"CREATE TABLE {$table_prefix}express_categories (
					cat_id mediumint(8) UNSIGNED NOT NULL auto_increment,
					cat_name varchar(255) DEFAULT '' NOT NULL,
					cat_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					cat_icon varchar(255) DEFAULT '' NOT NULL,
					cat_articles mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					cat_desc varchar(255) DEFAULT '' NOT NULL,
					display_on_index tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
					PRIMARY KEY (cat_id),
					KEY cat_order (cat_order)
				) CHARACTER SET `utf8` COLLATE `utf8_bin`;",

				"CREATE TABLE {$table_prefix}express_articles (
					article_id mediumint(8) UNSIGNED NOT NULL auto_increment,
					article_cat mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					article_title varchar(255) DEFAULT '' NOT NULL,
					article_intro text NOT NULL,
					article_content text NOT NULL,
					article_content_bitfield varchar(255) DEFAULT '' NOT NULL,
					article_content_options int(11) UNSIGNED DEFAULT '7' NOT NULL,
					article_content_uid varchar(8) DEFAULT '' NOT NULL,
					article_views mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					article_rates tinyint(2) UNSIGNED DEFAULT '0' NOT NULL,
					article_ratings mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					article_comments mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					article_image varchar(255) DEFAULT '' NOT NULL,
					article_similar varchar(255) DEFAULT '' NOT NULL,
					article_source varchar(255) DEFAULT '' NOT NULL,
					article_time int(11) UNSIGNED DEFAULT '0' NOT NULL,
					PRIMARY KEY (article_id)
				) CHARACTER SET `utf8` COLLATE `utf8_bin`;",

				"CREATE TABLE {$table_prefix}express_pages (
					page_id mediumint(8) UNSIGNED NOT NULL auto_increment,
					page_basename varchar(40) DEFAULT '' NOT NULL,
					page_name varchar(255) DEFAULT '' NOT NULL,
					page_custom tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
					page_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					page_icon varchar(255) DEFAULT '' NOT NULL,
					page_views mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					page_content text NOT NULL,
					page_content_bitfield varchar(255) DEFAULT '' NOT NULL,
					page_content_options int(11) UNSIGNED DEFAULT '7' NOT NULL,
					page_content_uid varchar(8) DEFAULT '' NOT NULL,
					page_time int(11) UNSIGNED DEFAULT '0' NOT NULL,
					template_file varchar(255) DEFAULT '' NOT NULL,
					language_file varchar(255) DEFAULT '' NOT NULL,
					PRIMARY KEY (page_id),
					KEY page_order (page_order)
				) CHARACTER SET `utf8` COLLATE `utf8_bin`;",

				"CREATE TABLE {$table_prefix}express_blocks (
					block_id mediumint(8) UNSIGNED NOT NULL auto_increment,
					block_title varchar(255) DEFAULT '' NOT NULL,
					block_type varchar(40) DEFAULT '' NOT NULL,
					block_position tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
					block_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					block_icon varchar(255) DEFAULT '' NOT NULL,
					block_text text NOT NULL,
					block_text_bitfield varchar(255) DEFAULT '' NOT NULL,
					block_text_options int(11) UNSIGNED DEFAULT '7' NOT NULL,
					block_text_uid varchar(8) DEFAULT '' NOT NULL,
					PRIMARY KEY (block_id),
					KEY block_order (block_order)
				) CHARACTER SET `utf8` COLLATE `utf8_bin`;",

				"CREATE TABLE {$table_prefix}express_links (
					link_id mediumint(8) UNSIGNED NOT NULL auto_increment,
					link_title varchar(255) DEFAULT '' NOT NULL,
					link_is_cat tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
					link_url varchar(255) DEFAULT '' NOT NULL,
					link_icon varchar(255) DEFAULT '' NOT NULL,
					link_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					PRIMARY KEY (link_id),
					KEY link_order (link_order)
				) CHARACTER SET `utf8` COLLATE `utf8_bin`;",

				"CREATE TABLE {$table_prefix}express_ads (
					ads_id mediumint(8) UNSIGNED NOT NULL auto_increment,
					ads_title varchar(255) DEFAULT '' NOT NULL,
					ads_url varchar(255) DEFAULT '' NOT NULL,
					ads_image varchar(255) DEFAULT '' NOT NULL,
					ads_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL,
					ads_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL,
					ads_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					ads_display tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
					ads_clicks mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					ads_text text NOT NULL,
					PRIMARY KEY (ads_id),
					KEY ads_display (ads_display),
					KEY ads_order (ads_order)
				) CHARACTER SET `utf8` COLLATE `utf8_bin`;",

				"CREATE TABLE {$table_prefix}express_rates (
					rate_id mediumint(8) UNSIGNED NOT NULL auto_increment,
					article_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					user_ip varchar(40) DEFAULT '' NOT NULL,
					rates tinyint(2) UNSIGNED DEFAULT '0' NOT NULL,
					PRIMARY KEY (rate_id)
				) CHARACTER SET `utf8` COLLATE `utf8_bin`;",

				"CREATE TABLE {$table_prefix}express_comments (
					comment_id mediumint(8) UNSIGNED NOT NULL auto_increment,
					article_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					poster_username varchar(255) DEFAULT '' NOT NULL,
					poster_colour varchar(6) DEFAULT '' NOT NULL,
					poster_ip varchar(40) DEFAULT '' NOT NULL,
					comment text NOT NULL,
					comment_bitfield varchar(255) DEFAULT '' NOT NULL,
					comment_options int(11) UNSIGNED DEFAULT '7' NOT NULL,
					comment_uid varchar(8) DEFAULT '' NOT NULL,
					comment_time int(11) UNSIGNED DEFAULT '0' NOT NULL,
					PRIMARY KEY (comment_id)
				) CHARACTER SET `utf8` COLLATE `utf8_bin`;",
			);
		}
		else
		{
			$sql_ary = array(
				"CREATE TABLE {$table_prefix}express_categories (
					cat_id mediumint(8) UNSIGNED NOT NULL auto_increment,
					cat_name varbinary(255) DEFAULT '' NOT NULL,
					cat_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					cat_icon varbinary(255) DEFAULT '' NOT NULL,
					cat_articles mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					cat_desc varbinary(255) DEFAULT '' NOT NULL,
					display_on_index tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
					PRIMARY KEY (cat_id),
					KEY cat_order (cat_order)
				);",

				"CREATE TABLE {$table_prefix}express_articles (
					article_id mediumint(8) UNSIGNED NOT NULL auto_increment,
					article_cat mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					article_title varbinary(255) DEFAULT '' NOT NULL,
					article_intro mediumblob NOT NULL,
					article_content mediumblob NOT NULL,
					article_content_bitfield varbinary(255) DEFAULT '' NOT NULL,
					article_content_options int(11) UNSIGNED DEFAULT '7' NOT NULL,
					article_content_uid varbinary(8) DEFAULT '' NOT NULL,
					article_views mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					article_rates tinyint(2) UNSIGNED DEFAULT '0' NOT NULL,
					article_ratings mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					article_comments mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					article_image varbinary(255) DEFAULT '' NOT NULL,
					article_similar varbinary(255) DEFAULT '' NOT NULL,
					article_source varbinary(255) DEFAULT '' NOT NULL,
					article_time int(11) UNSIGNED DEFAULT '0' NOT NULL,
					PRIMARY KEY (article_id)
				);",

				"CREATE TABLE {$table_prefix}express_pages (
					page_id mediumint(8) UNSIGNED NOT NULL auto_increment,
					page_basename varbinary(40) DEFAULT '' NOT NULL,
					page_name varbinary(255) DEFAULT '' NOT NULL,
					page_custom tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
					page_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					page_icon varbinary(255) DEFAULT '' NOT NULL,
					page_views mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					page_content mediumblob NOT NULL,
					page_content_bitfield varbinary(255) DEFAULT '' NOT NULL,
					page_content_options int(11) UNSIGNED DEFAULT '7' NOT NULL,
					page_content_uid varbinary(8) DEFAULT '' NOT NULL,
					page_time int(11) UNSIGNED DEFAULT '0' NOT NULL,
					template_file varbinary(255) DEFAULT '' NOT NULL,
					language_file varbinary(255) DEFAULT '' NOT NULL,
					PRIMARY KEY (page_id),
					KEY page_order (page_order)
				);",

				"CREATE TABLE {$table_prefix}express_blocks (
					block_id mediumint(8) UNSIGNED NOT NULL auto_increment,
					block_title varbinary(255) DEFAULT '' NOT NULL,
					block_type varbinary(40) DEFAULT '' NOT NULL,
					block_position tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
					block_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					block_icon varbinary(255) DEFAULT '' NOT NULL,
					block_text mediumblob NOT NULL,
					block_text_bitfield varbinary(255) DEFAULT '' NOT NULL,
					block_text_options int(11) UNSIGNED DEFAULT '7' NOT NULL,
					block_text_uid varbinary(8) DEFAULT '' NOT NULL,
					PRIMARY KEY (block_id),
					KEY block_order (block_order)
				);",

				"CREATE TABLE {$table_prefix}express_links (
					link_id mediumint(8) UNSIGNED NOT NULL auto_increment,
					link_title varbinary(255) DEFAULT '' NOT NULL,
					link_is_cat tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
					link_url varbinary(255) DEFAULT '' NOT NULL,
					link_icon varbinary(255) DEFAULT '' NOT NULL,
					link_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					PRIMARY KEY (link_id),
					KEY link_order (link_order)
				);",

				"CREATE TABLE {$table_prefix}express_ads (
					ads_id mediumint(8) UNSIGNED NOT NULL auto_increment,
					ads_title varbinary(255) DEFAULT '' NOT NULL,
					ads_url varbinary(255) DEFAULT '' NOT NULL,
					ads_image varbinary(255) DEFAULT '' NOT NULL,
					ads_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL,
					ads_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL,
					ads_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					ads_display tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
					ads_clicks mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					ads_text mediumblob NOT NULL,
					PRIMARY KEY (ads_id),
					KEY ads_display (ads_display),
					KEY ads_order (ads_order)
				);",

				"CREATE TABLE {$table_prefix}express_rates (
					rate_id mediumint(8) UNSIGNED NOT NULL auto_increment,
					article_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					user_ip varbinary(40) DEFAULT '' NOT NULL,
					rates tinyint(2) UNSIGNED DEFAULT '0' NOT NULL,
					PRIMARY KEY (rate_id)
				);",

				"CREATE TABLE {$table_prefix}express_comments (
					comment_id mediumint(8) UNSIGNED NOT NULL auto_increment,
					article_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
					poster_username varbinary(255) DEFAULT '' NOT NULL,
					poster_colour varbinary(6) DEFAULT '' NOT NULL,
					poster_ip varbinary(40) DEFAULT '' NOT NULL,
					comment mediumblob NOT NULL,
					comment_bitfield varbinary(255) DEFAULT '' NOT NULL,
					comment_options int(11) UNSIGNED DEFAULT '7' NOT NULL,
					comment_uid varbinary(8) DEFAULT '' NOT NULL,
					comment_time int(11) UNSIGNED DEFAULT '0' NOT NULL,
					PRIMARY KEY (comment_id)
				);",
			);
		}
	break;
}

// Begin running queries...
foreach ($sql_ary as $sql)
{
	$db->sql_query($sql);
}

// Insert default blocks
$block_list = array(
	'express_cats'		=> array('BLOCK_EXPRESS_CATS', '1', '1', 'newspaper.png', '', '', '7', ''),
	'board'				=> array('BLOCK_BOARD', '1', '2', 'arrow_refresh.png', '', '', '7', ''),
	'express_links'		=> array('BLOCK_EXPRESS_LINKS', '1', '3', 'world.png', '', '', '7', ''),
	'express_pages'		=> array('BLOCK_EXPRESS_PAGES', '1', '4', 'information.png', '', '', '7', ''),
	'special_articles'	=> array('BLOCK_SPECIAL_ARTICLES', '1', '5', 'asterisk_orange.png', '', '', '7', ''),
	'welcome'			=> array('BLOCK_WELCOME', '2', '6', 'vcard.png', '', '', '7', ''),
	'latest_news'		=> array('BLOCK_LATEST_NEWS', '2', '7', 'new.png', '', '', '7', ''),
	'hot_news'			=> array('BLOCK_HOT_NEWS', '2', '8', 'heart.png', '', '', '7', ''),
	'announcements'		=> array('BLOCK_ANNOUNCEMENTS', '2', '9', 'sound.png', '', '', '7', ''),
	'latest_topics'		=> array('BLOCK_LATEST_TOPICS', '2', '10', 'comment.png', '', '', '7', ''),
	'latest_posts'		=> array('BLOCK_LATEST_POSTS', '2', '11', 'comments.png', '', '', '7', ''),
	'top_topics'		=> array('BLOCK_TOP_TOPICS', '2', '12', 'lightning.png', '', '', '7', ''),
	'latest_files'		=> array('BLOCK_LATEST_FILES', '2', '13', 'box.png', '', '', '7', ''),
	'top_files'			=> array('BLOCK_TOP_FILES', '2', '14', 'disk.png', '', '', '7', ''),
	'top_posters'		=> array('BLOCK_TOP_POSTERS', '2', '15', 'group.png', '', '', '7', ''),
	'newest_users'		=> array('BLOCK_NEWEST_USERS', '2', '16', 'user.png', '', '', '7', ''),
	'last_visited_bots'	=> array('BLOCK_LAST_VISITED_BOTS', '2', '17', 'bug.png', '', '', '7', ''),
	'poll'				=> array('BLOCK_POLL', '5', '18', 'chart_bar.png', '', '', '7', ''),
	'rss'				=> array('BLOCK_RSS', '6', '19', 'transmit.png', '', '', '7', ''),
	'online'			=> array('BLOCK_ONLINE', '4', '20', 'emoticon_smile.png', '', '', '7', ''),
	'visited_today'		=> array('BLOCK_VISITED_TODAY', '4', '21', 'flag_red.png', '', '', '7', ''),
	'counter'			=> array('BLOCK_COUNTER', '1', '22', 'chart_pie.png', '', '', '7', ''),
	'statistics'		=> array('BLOCK_STATISTICS', '1', '23', 'bricks.png', '', '', '7', ''),
	'birthday'			=> array('BLOCK_BIRTHDAY', '1', '24', 'cake.png', '', '', '7', ''),
	'quotes'			=> array('BLOCK_QUOTES', '1', '25', 'script.png', '', '', '7', ''),
	'search'			=> array('BLOCK_SEARCH', '1', '26', 'zoom.png', '', '', '7', ''),
	'express_ads'		=> array('BLOCK_EXPRESS_ADS', '1', '27', 'star.png', '', '', '7', ''),
	'timer'				=> array('BLOCK_TIMER', '2', '28', 'clock.png', '', '', '7', ''),
	'website_info'		=> array('BLOCK_WEBSITE_INFO', '2', '29', 'building.png', '', '', '7', ''),
	'paypal'			=> array('BLOCK_PAYPAL', '1', '30', 'money.png', '', '', '7', ''),
	'custom'			=> array('مبروك تم تنصيب النسخة bb4dd 2.0.0', '3', '31', 'application_double.png', '!تم التنصيب, بنجاح
ابقى على اتصال بالموقع الرسمي للنسخة <!-- w --><a class="postlink" href="http://www.bb4dd.com">http://www.bb4dd.com</a><!-- w -->

تستطيع مقابلتنا في :الإمارات , أبوظبي , ت:00971505918399

يمكنك أن تشكرني من خلال [url=http&#58;//www&#46;bb4dd&#46;com/ar/community/:3qqfpzbh]موقع الدعم الخاص بالنسخة[/url:3qqfpzbh].', 'UA==', '7', '3qqfpzbh'),
);

foreach ($block_list as $block => $block_ary)
{
	$sql_ary = array(
		'block_title'			=> $block_ary[0],
		'block_type'			=> $block,
		'block_position'		=> $block_ary[1],
		'block_order'			=> $block_ary[2],
		'block_icon'			=> $block_ary[3],
		'block_text'			=> $block_ary[4],
		'block_text_bitfield'	=> $block_ary[5],
		'block_text_options'	=> $block_ary[6],
		'block_text_uid'		=> $block_ary[7],
	);

	$sql = 'INSERT INTO ' . EXPRESS_BLOCKS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
	$db->sql_query($sql);
}

// Insert example advertisements
$ads_list = array(
	'bb4dd_logo.png'	=> array('bb4dd', 'http://www.bb4dd.com/', '152', '60', '3', '1', '0', 'Community your site'),
);

foreach ($ads_list as $ads => $ads_ary)
{
	$sql_ary = array(
		'ads_title'		=> $ads_ary[0],
		'ads_url'		=> $ads_ary[1],
		'ads_image'		=> $ads,
		'ads_width'		=> $ads_ary[2],
		'ads_height'	=> $ads_ary[3],
		'ads_order'		=> $ads_ary[4],
		'ads_display'	=> $ads_ary[5],
		'ads_clicks'	=> $ads_ary[6],
		'ads_text'		=> $ads_ary[7],
	);

	$sql = 'INSERT INTO ' . EXPRESS_ADS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
	$db->sql_query($sql);
}

// Insert example links
$link_list = array(
	'bb4dd'	=> array('http://www.bb4dd.com/', '0', 'html.png', '1'),
	'phpBB'				=> array('http://www.phpbb.com/', '0', 'bullet_black.png', '2'),
	'MaYaForums'			=> array('http://www.mayaforums.net/', '0', 'bullet_blue.png', '3'),
);

foreach ($link_list as $link => $link_ary)
{
	$sql_ary = array(
		'link_title'	=> $link,
		'link_is_cat'	=> $link_ary[1],
		'link_url'		=> $link_ary[0],
		'link_icon'		=> $link_ary[2],
		'link_order'	=> $link_ary[3],
	);

	$sql = 'INSERT INTO ' . EXPRESS_LINKS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
	$db->sql_query($sql);
}

// Insert example categories
$cat_list = array(
	'world.png'	=> array('bb4dd', '1', '2', 'Go anywhere over the world', '1'),
);

foreach ($cat_list as $cat => $cat_ary)
{
	$sql_ary = array(
		'cat_name'			=> $cat_ary[0],
		'cat_icon'			=> $cat,
		'cat_order'			=> $cat_ary[1],
		'cat_articles'		=> $cat_ary[2],
		'cat_desc'			=> $cat_ary[3],
		'display_on_index'	=> $cat_ary[4],
	);

	$sql = 'INSERT INTO ' . EXPRESS_CATEGORIES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
	$db->sql_query($sql);
}

// Insert example articles
$article_list = array(
	'bb4dd_logo.png'	=> array('1', 'Test for bb4dd article', 'Ha Long Bay, in the Gulf of Tonkin, includes some 1,600 islands and islets, forming a spectacular seascape of limestone pillars. Because of their precipitous nature, most of the islands are uninhabited and unaffected by a human presence. The site\'s outstanding scenic beauty is complemented by its great biological interest.', 'Ha Long Bay is in Northern Viet Nam near the Chinese border. The landscape around the bay is extraordinary. This quiet port has received an increasing number of visitors from all over the world since its addition to the World Heritage list in 1994.

&quot;Ha Long&quot; in Vietnamese means &quot;Descending Dragon&quot;. The bay was named after a local legend which says that a Dragon descended from the sky and spat out thousands of pearls when Viet Nam was being attacked by foreign ships. The pearls then became a multitude of small islands and prevented the enemy from advancing further.

Ha Long Bay is also known as the &quot;Guilin on the Sea&quot;, because the seabed, which is a sunken limestone plateau, connects all the way to Guilin in China.

This is an exceptional example of such a great number of limestone islands spreading out over such a large area. There are some peculiar shaped rocks. Two rocks here are facing each other. The Vietnamese named them &quot;Fighting Cocks\' Islands&quot;. Cock-fighting is a national passion in Viet Nam. This is the &quot;Dog Rock&quot;.

On another side of Ha Long Bay ... there is a ... village built on the sea. A village on water. The local people built houses on rafts. A woman cradles a baby ... Another does her washing on board. The main source of income is fishing. People live here with the blessing of the sea. Children even row to school.

The Bay is a remarkable example of world heritage.', '', '7', '', '0', '2', 'UNESCO World Heritage Centre', time(), '0', '0', '0'),
	'bb4dd_logo.png'			=> array('1', 'Ha Long Gallery', 'Ha Long Bay is a UNESCO World Heritage site located in Quang Ninh province, Vietnam. The bay features thousands of limestone karsts and isles in various sizes and shapes.', '[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_01&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_02&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_03&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_04&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_05&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_06&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_07&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_08&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_09&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_10&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_11&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_12&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_13&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_14&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_15&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_16&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_17&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_18&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_19&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_20&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_21&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_22&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_23&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_24&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_25&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_26&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_27&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_28&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_29&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_30&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_31&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_32&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_33&#46;jpg[/img:2tglfvuc]
[img:2tglfvuc]http&#58;//bb4dd&#46;com/data/images/misc/01_34&#46;jpg[/img:2tglfvuc]', 'CA==', '7', '2tglfvuc', '0', '1', '', time(), '0', '0', '0'),
);

foreach ($article_list as $article => $article_ary)
{
	$sql_ary = array(
		'article_cat'				=> $article_ary[0],
		'article_title'				=> $article_ary[1],
		'article_intro'				=> $article_ary[2],
		'article_content'			=> $article_ary[3],
		'article_content_bitfield'	=> $article_ary[4],
		'article_content_options'	=> $article_ary[5],
		'article_content_uid'		=> $article_ary[6],
		'article_views'				=> $article_ary[7],
		'article_image'				=> $article,
		'article_similar'			=> $article_ary[8],
		'article_source'			=> $article_ary[9],
		'article_time'				=> $article_ary[10],
		'article_rates'				=> $article_ary[11],
		'article_ratings'			=> $article_ary[12],
		'article_comments'			=> $article_ary[13],
	);

	$sql = 'INSERT INTO ' . EXPRESS_ARTICLES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
	$db->sql_query($sql);

	if ($db->sql_affectedrows())
	{
		set_config('express_index_articles', '1');
	}
	else
	{
		set_config('express_index_articles', '');
	}
}

// Insert example pages
$page_list = array(
	'application_home.png'	=> array('bb4dd', 'Why bb4dd is not a software?', '1', '1', '0', 'Because it is just my breakfast...

[img:1ddmma73]http&#58;//bb4dd&#46;com/data/images/misc/phpbb_nuixao&#46;jpg[/img:1ddmma73]', 'CA==' , '7', '1ddmma73', time(), '', ''),
);

foreach ($page_list as $page => $page_ary)
{
	$sql_ary = array(
		'page_basename'			=> $page_ary[0],
		'page_name'				=> $page_ary[1],
		'page_custom'			=> $page_ary[2],
		'page_order'			=> $page_ary[3],
		'page_icon'				=> $page,
		'page_views'			=> $page_ary[4],
		'page_content'			=> $page_ary[5],
		'page_content_bitfield'	=> $page_ary[6],
		'page_content_options'	=> $page_ary[7],
		'page_content_uid'		=> $page_ary[8],
		'page_time'				=> $page_ary[9],
		'template_file'			=> $page_ary[10],
		'language_file'			=> $page_ary[11],
	);

	$sql = 'INSERT INTO ' . EXPRESS_PAGES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
	$db->sql_query($sql);
}

// Insert new permissions
$acl_options = array(
	'a_express' => array('1', '0', '0'),
	'u_express' => array('1', '0', '0'),
);

foreach ($acl_options as $acl => $acl_ary)
{
	$sql_ary = array(
		'auth_option'	=> $acl,
		'is_global'		=> $acl_ary[0],
		'is_local'		=> $acl_ary[1],
		'founder_only'	=> $acl_ary[2],
	);

	$sql = 'INSERT INTO ' . ACL_OPTIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
	$db->sql_query($sql);
}

// Detect any topic contained a poll
$sql = 'SELECT topic_id
	FROM ' . TOPICS_TABLE . "
	WHERE poll_title <> ''";
$result = $db->sql_query_limit($sql, 1);
$poll_topic_id = (int) $db->sql_fetchfield('topic_id');
$db->sql_freeresult($result);

if ($poll_topic_id)
{
	set_config('block_poll_topic_id', $poll_topic_id);
}
else
{
	set_config('block_poll_topic_id', '');
}

// Config values
set_config('express_icons_path', 'images/express/icons');
set_config('express_article_images_path', 'images/express/article_images');
set_config('express_ads_path', 'images/express/ads');
set_config('express_last_updated', time());
set_config('express_articles_per_cat', '3');
set_config('express_articles_per_page', '10');
set_config('express_more_articles_limit', '20');
set_config('express_feed_limit', '20');
set_config('express_items_per_toplist', '10');
set_config('express_ads_contact', '');
set_config('express_copyright', '');
set_config('counter_digits_path', 'images/counter/digits');
set_config('counter_digits_ani_path', 'images/counter/digits_ani');
set_config('counter_ip_logfile', 'images/counter/ip.txt');
set_config('counter_digits_number', '6');
set_config('counter_block_ip', '1');
set_config('counter_block_time', '60');
set_config('counter_startdate', time());
set_config('counter_display_mode', '1');
set_config('counter_display_stats', '1');

// Blocks (Load settings)
set_config('block_hot_news', '1');
set_config('block_latest_news', '1');
set_config('block_latest_topics', '1');
set_config('block_latest_posts', '1');
set_config('block_newest_users', '1');
set_config('block_last_visited_bots', '1');
set_config('block_top_posters', '1');
set_config('block_top_topics', '1');
set_config('block_express_cats', '1');
set_config('block_express_pages', '1');
set_config('block_express_ads', '1');
set_config('block_special_articles', '1');
set_config('block_counter', '1');
set_config('block_paypal', '1');
set_config('block_paypal_name', '');
set_config('block_paypal_email', '');
set_config('block_paypal_country', '');
set_config('block_online', '1');
set_config('block_board', '1');
set_config('block_poll', '1');
set_config('block_rss', '1');
set_config('block_rss_publishers', 'http://bb4dd.com/ar/community/feed.php?mode=rss');
set_config('block_rss_limit', '5');
set_config('block_rss_time', '60');
set_config('block_search', '1');
set_config('block_timer', '1');
set_config('block_visited_today', '1');
set_config('block_announcements', '1');
set_config('block_latest_files', '1');
set_config('block_top_files', '1');
set_config('block_quotes', '1');
set_config('block_welcome', '1');
set_config('block_website_info', '1');
set_config('block_express_links', '1');

// Dynamic keys
set_config('counter_hits', '0', true);

$sql = 'SELECT COUNT(cat_id) AS stat
	FROM ' . EXPRESS_CATEGORIES_TABLE;
$result = $db->sql_query($sql);
set_config('num_express_cats', (int) $db->sql_fetchfield('stat'), true);
$db->sql_freeresult($result);

$sql = 'SELECT COUNT(article_id) AS stat
	FROM ' . EXPRESS_ARTICLES_TABLE;
$result = $db->sql_query($sql);
set_config('num_express_articles', (int) $db->sql_fetchfield('stat'), true);
$db->sql_freeresult($result);

$sql = 'SELECT COUNT(page_id) AS stat
	FROM ' . EXPRESS_PAGES_TABLE;
$result = $db->sql_query($sql);
set_config('num_express_pages', (int) $db->sql_fetchfield('stat'), true);
$db->sql_freeresult($result);

$sql = 'SELECT COUNT(block_id) AS stat
	FROM ' . EXPRESS_BLOCKS_TABLE;
$result = $db->sql_query($sql);
set_config('num_express_blocks', (int) $db->sql_fetchfield('stat'), true);
$db->sql_freeresult($result);

$sql = 'SELECT COUNT(link_id) AS stat
	FROM ' . EXPRESS_LINKS_TABLE;
$result = $db->sql_query($sql);
set_config('num_express_links', (int) $db->sql_fetchfield('stat'), true);
$db->sql_freeresult($result);

page_header('bb4dd Portal 2.0.0 - Installer');

$cache->purge();

trigger_error('تم تنصيب قواعد بيانات المجلة بنجاح ...... تم تنصيب النسخة بنجاح ... الآن توجه الى موقعك وتفحصه جيدا واذا وجدت أي خطأ الرجاء الابلاغ عنه في موقع النسخة الرسمي ... <a href="http://bb4dd.com/ar/community">http://www.bb4dd.com</a>');

?>